﻿using RMS.API.Web.Models.Temp;
using RMS.BLL;
using RMS.Common;
using RMS.EF.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace RMS.API.Web.Areas.RMS.Controllers
{
    /// <summary>
    /// 用户接口
    /// </summary>
    [RoutePrefix("api/RMS/User")]
    public class UserController : ApiController
    {

        UserBll bll = new UserBll();
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="model">登录信息</param>
        /// <returns></returns>
        [HttpPost]
        [Route("Login")]
        public CommonOutPutVm Login(Login_TempModel model)
        {
            var result = new CommonOutPutVm();
            var modelV = new RMS_User() { UserName = model.UserName, Password = model.Password };
            result = bll.Login(modelV);
            return result;
        }
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="model">修改信息</param>
        /// <returns></returns>
        [HttpPost]
        [Route("EditPassword")]
        public CommonOutPutVm EditPassword(EditPassword_TempModel model)
        {
            var result = new CommonOutPutVm();
            result = bll.EditPassword(model.UserId, model.OrgPwd, model.NewPwd,model.RePwd);
            return result;
        }

        
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="page">分页参数</param>
        /// <param name="searchModel">搜索参数</param>
        /// <returns></returns>
        [HttpPost]
        [Route("GetByPage")]
        public CommonOutPutVm GetByPage(PageParamsT<S_RMS_User> page)
        {
            var result = new CommonOutPutVm();
            result = bll.GetByPage(page);
            return result;
        }
        
    }
}